#ifndef _STEPPERPOSITION_H_
#define _STEPPERPOSITION_H_
#include "sys.h"
#ifdef __cplusplus
 extern "C" {
#endif

#define ITSTATE				0x01
#define NORMALSTATE			0x00

typedef struct StepperPosDataStruct{
	uint16_t currentcnt;
	uint16_t startcnt;
	uint32_t deltacnt;
	uint32_t temp_deltacnt;
    uint32_t ITdeltacnt;
	int32_t lastposition;
	int32_t position;
	uint8_t (*PosInitLimit)(void);
	uint8_t posinit_dir;
}StepperPosDataStruct;

void StepperPosDataInit(StepperPosDataStruct* p_posdata);
void SetStepperStartCnt(StepperPosDataStruct* p_posdata,uint16_t startcnt);
void SetStepperCurrentCnt(uint8_t ID,StepperPosDataStruct* p_posdata);
void GetStepperITDeltaCnt(StepperPosDataStruct* p_posdata);
void GetStepperDeltaCnt(uint8_t state,StepperPosDataStruct* p_posdata);
void UpdatePosition(uint8_t dir,StepperPosDataStruct* p_posdata);

#ifdef __cplusplus
}
#endif
#endif 

